using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Afrs.Draco.Prms.Client.Proxy;
using Afrs.Prms.DataObject;

namespace 
{
  /// <summary>
  /// Tusers Test Class
  /// </summary>
  [TestClass]
  public class TestTusers
  {
    #region Class Variables
    private CdoPrms<DOTusers>		m_Tusers;
    private CdoPrmsList<DOTusers>	m_AllTusers;
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Constructs the test
    /// </summary>
    public TestTusers()
    {
      // Create the data objects
      this.m_Tusers	= new CdoPrms<DOTusers>();
      this.m_AllTusers	= new CdoPrmsList<DOTusers>();
    }
    #endregion

    #region Class Methods
    /// <summary>
    /// Retrieves all Tusers data objects
    /// </summary>
    [TestMethod]
    public void TusersRetrieveAll()
    {
      // Set up the data object for list retrieval
      this.m_AllTusers.DataObject = new DOTusers();
      this.m_AllTusers.ListAction = AfrsDOListAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_AllTusers.PerformAction())
      {
        // Assert the errors
        if (this.m_AllTusers.Errors.Count > 0) { Assert.Fail(this.m_AllTusers.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Create a new Tusers
    /// </summary>
    [TestMethod]
    public void TusersCreate()
    {
      // Set up the data object for creation
      this.m_Tusers.DataObject.PASSWORD = 'b';
      this.m_Tusers.DataObject.ACCESS = new byte[] { 1, 2, 3 };
      this.m_Tusers.DataObject.NAME = 'b';
      this.m_Tusers.DataObject.Action = AfrsDataObjectAction.Create;

      // Perform the action and determine the success
      if (!this.m_Tusers.PerformAction())
      {
        // Assert the errors
        if (this.m_Tusers.Errors.Count > 0) { Assert.Fail(this.m_Tusers.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Retrieves a specific Tusers
    /// </summary>
    [TestMethod]
    public void TusersRetrieve()
    {
      // Determine whether the data object needs to be specified
      if (this.m_Tusers.DataObject.Id == 0)
      {
        // Specify the data object to retrieve
        this.m_Tusers.DataObject.TUSER = 'b';
      }

      // Set up the data object action for retrieval
      this.m_Tusers.DataObject.Action = AfrsDataObjectAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_Tusers.PerformAction())
      {
        // Assert the errors
        if (this.m_Tusers.Errors.Count > 0) { Assert.Fail(this.m_Tusers.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }
    #endregion
  }
}
